<p id="notice"><%= notice %></p>

<h1><%=@post.title%></h1>
<div class="post-info">Posteado por <span><%=@post.user.name%> <%=@post.user.last_name%></span> el <span><a><%=@post.created_at%></a></span>, commentarios <%=@post.comments.count%> Nota ( <%=@post.rate%> )</div>

<p><%= @post.content %> </p>
<div class="attachment">
	<%=link_to @post.file_file_name, @post.file.url(:original, false)%> &nbsp;&nbsp;<%=@post.file_file_size%> bytes
</div>
<%if @post.comments.any?%><h2>Commentarios</h2>
	<% @post.comments.each do |comment| %>
	<%if comment.depth ==0%>
    	<%= nested_comments comment.subtree.arrange(:order => :created_at) %>
	<%end%>
	<%end%>
	
<%end%>

<%if can? :create, @comment%>
	<div class="comment">
		<%= form_for(@post.comments.build) do |f| %>
		  <div class="field">
			<%= f.hidden_field :post_id%>
			<%= f.hidden_field :user_id, :value=> @current_user.id%>
		    <b><%= f.label :body, "Comentar post: " %></b>
		    <%= f.text_area :body,:rows => 3 %>
			<%= f.label :rating %></b>
		    <%= f.select(:rating, [1,2,3,4,5,6,7], :selected => 4) %>
		  </div>
		  <div class="actions">
		    <%= f.submit %>
		  </div>
		<% end %>
	</div>
<%end%>



<%= link_to 'Edit', edit_post_path(@post) %> |
<%= link_to 'Back', posts_path %>
